import React, {PropsWithChildren} from 'react'
import {Text, View} from "@tarojs/components";
import styles from "./mine.module.sass"
import MyNavigationBar from "../components/MyNavigationBar";
import Taro, {useDidShow} from "@tarojs/taro";
import {setTabBarState} from "../custom-tab-bar/TabBarUtils";
import {Avatar, Button, Space} from "@nutui/nutui-react-taro";
import {User} from "@nutui/icons-react-taro";
import employeeStore from "../store/EmployeeStore";
import authorizationStore from "../store/AuthorizationStore";

export interface MineProps extends PropsWithChildren {

}

const Mine: React.FC<MineProps> = ({}) => {
    useDidShow(() => {
        setTabBarState(1)
    })
    return <>
        <MyNavigationBar>我的</MyNavigationBar>
        <View className={styles.container}>
            <View className={styles.header}>
                <Avatar icon={<User/>} shape={"round"} size={"large"}/>
                <View className={styles.names}>
                    <Text className={styles.name}>{employeeStore.employee?.name}</Text>
                    <Text className={styles.enterpriseName}>{employeeStore.employee?.systemService.name}</Text>
                </View>
            </View>
            <Space direction={"vertical"}>
                <Button block fill={"outline"} onClick={async () => {
                    Taro.navigateTo({
                        url: "/pages/updatePassword"
                    })
                }}>修改密码</Button>
                <Button block fill={"outline"} onClick={async () => {
                    await authorizationStore.logOut()
                    Taro.reLaunch({
                        url: "/pages/logIn"
                    })
                }}>退出登录</Button>
            </Space>
        </View>
    </>
}

export default Mine


